/**
 * 
 */
package com.bj58.data.hadoop.info.entry;


import java.util.HashMap;
import java.util.Map;

import com.bj58.data.hadoop.info.tools.InfoField;
import com.bj58.data.hadoop.info.tools.InfoString;
import com.bj58.data.hadoop.info.tools.Params;


/**
 * @author zhangpeng
 *
 */
public class InfoEntry {

	public static final String ALL = "A";
	
	public InfoEntry(String[] infoArray)
	{
		String tempUserID = "";
		try
		{
			tempUserID = infoArray[InfoField.UserID];
		}
		catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println("userID:"+userID);
		}
		finally
		{
			userID = tempUserID;
		}
		
		String cateID = "";
		try
		{
			cateID = infoArray[InfoField.CateID];
		}
		catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println("cateID:"+cateID);
		}
		finally
		{
			String[] cates = cateID.split(",");
			if(cates.length > 1)
			{
				this.cateFirst = cates[1];
			}
			if(cates.length > 2)
			{
				this.cateSecond = cates[2];
			}
		}
		
		String bussiness = "";
		try
		{
			bussiness = infoArray[InfoField.BusinessLine];
		}
		catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println("bussiness:"+bussiness);
		}
		finally
		{
			String[] bussinesses = bussiness.split(",");
			if(bussinesses.length > 0)
			{
				this.businessFirsts = bussinesses[0];
				if(bussinesses[0].equals(""))
				{
					System.out.println(bussiness);
				}
			}
			if(bussinesses.length > 1)
			{
				this.businessSeconds = bussinesses[1];
			}
		}
		
		String disLocal = "";
		try
		{
			disLocal = infoArray[InfoField.DisLocalID];
		}
		catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println("disLocal:"+disLocal);
		}
		finally
		{
			String[] dispLocals = disLocal.split(",");
			if(dispLocals.length > 1)
			{
				this.dispLocalFirst = dispLocals[1];
			}
			if(dispLocals.length > 2)
			{
				this.dispLocalSencond = dispLocals[2];
			}
			if(dispLocals.length > 3)
			{
				this.dispLocalThird = dispLocals[3];
			}
			if(dispLocals.length > 4)
			{
				this.dispLocalFourth = dispLocals[4];
			}
		}
		
		String state = "";
		try
		{
			state = infoArray[InfoField.State];	
		}
		catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println("state:"+state);
		}
		finally
		{
			states = state;
		}
		
		String upType = "";
		try
		{
			upType = infoArray[InfoField.UpType];	
		}
		catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println("upType:"+upType);
		}
		finally
		{
			upTypes = upType;
		}
		
		String isBiz = "0";
		try
		{
			if(infoArray[InfoField.IsBiz].toString().equals("true"))
			{
				isBiz = "1";	
			}
		}
		catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println("isBiz:"+isBiz);
		}
		finally
		{
			isBizs = isBiz;
		}
	
	
		String source = "0";
		try
		{
			source = infoArray[InfoField.Source];	
		}
		catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println("source:"+source);
		}
		finally
		{
			sources = source;
		}
	
		String isCheck = "0";
		try
		{
			if(infoArray[InfoField.IsCheck].toString().equals("true"))
			{
				isCheck = "1";	
			}
		}
		catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println("isCheck:"+isCheck);
		}
		finally
		{
			isChecks = isCheck;
		}
		
		String checkType = "0";
		try
		{
			checkType = infoArray[InfoField.CheckType];	
		}
		catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println("checkType:"+checkType);
		}
		finally
		{
			checktypes = checkType;
		}
		
		String isPic = "";
		try
		{
			isPic = infoArray[InfoField.Pic];
		}
		catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println("isPic:"+isPic);
		}
		finally
		{
			isPics = isPic;
		}
	
		String newPerson = "";
		try
		{
			newPerson = infoArray[InfoField.IsNewPerson];
		}
		catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println("newPerson:"+newPerson);
		}
		finally
		{
			newPersons = newPerson;
		}
		
		
		Map<String,String> paramMap = new HashMap<String,String>();
		String param = "";
	
		try
		{
			param = infoArray[InfoField.Params];
			paramMap = Params.getParamsKV(param);
		}
		catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println("param:"+param);
		}
		finally
		{
			params = paramMap;
			if(params == null)
			{
				params = new HashMap<String,String>();
			}
		}
		
		String insertDate =  infoArray[InfoField.InsertDate];
		InsertDate = InfoString.formatTime(insertDate);
	}
	
	private String infoID="";
	
	private String userID="";
	
	private String cateFirst="";
	
	private String cateSecond="";
	
	private String businessFirsts="";
	
	private String businessSeconds="";
	
	public String getBusinessFirsts() {
		return businessFirsts;
	}

	public void setBusinessFirsts(String businessFirsts) {
		this.businessFirsts = businessFirsts;
	}

	public String getBusinessSeconds() {
		return businessSeconds;
	}

	public void setBusinessSeconds(String businessSeconds) {
		this.businessSeconds = businessSeconds;
	}

	private String dispLocalFirst="";
	
	private String dispLocalSencond="";
	
	private String dispLocalThird="";
	
	private String dispLocalFourth="";
	
	public String getDispLocalFirst() {
		return dispLocalFirst;
	}

	public void setDispLocalFirst(String dispLocalFirst) {
		this.dispLocalFirst = dispLocalFirst;
	}

	public String getDispLocalSencond() {
		return dispLocalSencond;
	}

	public void setDispLocalSencond(String dispLocalSencond) {
		this.dispLocalSencond = dispLocalSencond;
	}

	public String getDispLocalThird() {
		return dispLocalThird;
	}

	public void setDispLocalThird(String dispLocalThird) {
		this.dispLocalThird = dispLocalThird;
	}

	public String getDispLocalFourth() {
		return dispLocalFourth;
	}

	public void setDispLocalFourth(String dispLocalFourth) {
		this.dispLocalFourth = dispLocalFourth;
	}
	
	private String upTypes="";/**/
	
	private String isBizs="";/**/

	private String states="";/**/
	
	private String sources="";/**/
	
	private String isChecks="";/**/
	
	private String checktypes="";/**/
	
	private String isPics="";/**/
	
	private String newPersons="";/**/
	
	private Map<String,String> params;/**/
	
	private String InsertDate;
		
	public String getInsertDate() {
		return InsertDate;
	}

	public void setInsertDate(String insertDate) {
		InsertDate = insertDate;
	}

	public String getIsChecks() {
		return isChecks;
	}

	public void setIsChecks(String isChecks) {
		this.isChecks = isChecks;
	}

	public String getChecktypes() {
		return checktypes;
	}

	public void setChecktypes(String checktypes) {
		this.checktypes = checktypes;
	}

	public String getIsPics() {
		return isPics;
	}

	public void setIsPics(String isPics) {
		this.isPics = isPics;
	}

	public String getNewPersons() {
		return newPersons;
	}

	public void setNewPersons(String newPersons) {
		this.newPersons = newPersons;
	}

	
	public Map<String, String> getParams() {
		return params;
	}

	public void setParams(Map<String, String> params) {
		this.params = params;
	}

	public String getSources() {
		return sources;
	}

	public void setSources(String source) {
		this.sources = source;
	}

	public String getIsBizs() {
		return isBizs;
	}

	public void setIsBizs(String isBizs) {
		this.isBizs = isBizs;
	}

	public String getCateFirst() {
		return cateFirst;
	}

	public void setCateFirst(String cateFirst) {
		this.cateFirst = cateFirst;
	}

	public String getCateSecond() {
		return cateSecond;
	}

	public void setCateSecond(String cateSecond) {
		this.cateSecond = cateSecond;
	}

	public String getInfoID() {
		return infoID;
	}

	public String getUserID() {
		return userID;
	}

	public void setUserID(String userID) {
		this.userID = userID;
	}

	public void setInfoID(String infoID) {
		this.infoID = infoID;
	}
	
	public String getUpTypes() {
		return upTypes;
	}
	
	public void setUpTypes(String upTypes) {
		this.upTypes = upTypes;
	}
	
	public String getStates() {
		return states;
	}
	
	public void setStates(String states) {
		this.states = states;
	}
}
